//
//  THGlobalTool.m
//  TaiHao
//
//  Created by LeeSongtao on 16/6/1.
//  Copyright © 2016年 rzm. All rights reserved.
//

#import "SampuxGlobalTool.h"

@implementation SampuxGlobalTool

#pragma mark 根据字符串文字和字体计算尺寸
+ (CGSize)getSizeWithString:(NSString *)string andFont:(UIFont *)font andMaxSize:(CGSize)size
{
    //    CGSize getSize = CGSizeMake(30, 30);
    CGRect rect = [string boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:font} context:nil];
    CGSize getSize = CGSizeMake(rect.size.width, rect.size.height);
    return getSize;
}
//#pragma mark 根据字符串文字和字体计算尺寸
+ (CGSize)getSizeWithAttString:(NSAttributedString *)attString andMaxSize:(CGSize)size
{
    //    CGSize getSize = CGSizeMake(30, 30);
    CGRect rect = [attString boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin context:nil];
    CGSize getSize = CGSizeMake(rect.size.width, rect.size.height);
    return getSize;
}

+ (NSMutableAttributedString *)addAttributeline:(NSString *)str
{
    NSMutableAttributedString *content = [[NSMutableAttributedString alloc]initWithString:str];
    NSRange contentRange = {0,[content length]};
    [content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
    return content;
}

+ (NSArray *)createArrWithMin:(NSInteger)min andMax:(NSInteger)max
{
    NSMutableArray *array = [NSMutableArray array];
    for (int i = (int)min; i <= max ; i ++) {
        [array addObject:[NSString stringWithFormat:@"%d",i]];
    }
    return
    [NSArray arrayWithArray:array];
}


+ (NSString *)getApplicationVersionCode
{
    return [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)@"CFBundleShortVersionString"];
}

+ (NSString *)getApplicationName
{
    return [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey];
}

+ (NSString *)getDeviceName
{
    return [UIDevice currentDevice].model;
}

+ (NSString *)getApplicationBundleID
{
    return [NSBundle mainBundle].bundleIdentifier;
}

+ (NSString *)getSystemIOSVersion
{
    NSString *version = [NSString stringWithFormat:@"%@",[[UIDevice currentDevice] systemVersion]];
    return  version;
}

@end
